<?php $this->load->view('admin/inc/header'); ?>
<div id="maincontainer">
    <?php $this->load->view('admin/inc/menu_admin'); ?>
</div><!--end #maincontainer-->
<<div class="content_ng">
    <h1><?php echo $title; ?></h1>
    <?php echo $message; ?>
    <form method="post" action="<?php echo $action; ?>">
        <div class="data">
            <table>
                <tr>
				<td width="30%">ID</td>
				<td><input type="text" name="id" disabled="disable" class="text" value="<?php echo set_value('id'); ?>"/></td>
				<input type="hidden" name="id" value="<?php echo set_value('id',$this->form_data->id); ?>"/>
			</tr>
            <?php
                $this->load->library('Services_JSON');//load thư viện Serviecs_JSON
                $nganhArray = array();
                foreach($nganh ->result_array() as $row){
                    $nganhArray[] = $row;
                }

                $monArray = array();
                foreach($mon ->result_array() as $row){
                    $monArray[] = $row;
                }
                $json = new Services_JSON();
                $jsonNganh = $json->encodeUnsafe($nganhArray);
                $jsonMon = $json->encodeUnsafe($monArray);
            ?>
			<tr>
				<td valign="top">Ngành (Khoa)<span style="color:red;">*</span></td>
				<td>
                    <select name='id_nganh' id="id_nganh" />
                        <option value=''>Chọn ngành</option>
                        <?php foreach($nganhArray as $row):?>
                        <option value="<?php echo $row['id'];?>"><?php echo $row['ten_nganh'];?></option>
                        <?php endforeach;?>
				</td>
			</tr>
            <tr>
				<td valign="top">Môn <span style="color:red;">*</span></td>
				<td>
                   <select id="id_mon">
                        <option value="">Chọn môn</option>
                    </select>
                    <script type="text/javascript" src="<?php echo base_url();?>public/js/jquery.json.min.js"></script>
                    <script type="text/javascript">
                        $(document).ready(function() {
                            var monlist = $.evalJSON('<?php echo $jsonMon; ?>');
                            $('#id_nganh').bind('change', function() {
                                var string = '<option value="">Chọn môn</option>';
                                var ID_NGANH = this.value;
                                for (var i=0; i < monlist.length; i++) {//Hiển thị ra tất cả các dòng trong bảng
                                    if (monlist[i].nganh == ID_NGANH) {
                                        document.getElementById('id_mon').value = monlist[i].id;
                                        string += '<option value="' + monlist[i].id + '">' + monlist[i].ten_mon + '</option>';
                                    }
                                }
                                $('#id_mon').html(string);
                                $('#id_mon').css('display','block');

                            });
                        });
                    </script>
				</td>
			</tr>
            <tr>
				<td valign="top">Tên Khóa Học<span style="color:red;">*</span></td>
				<td><input type="text" name="ten_khoahoc" size="90px" class="text" value="<?php echo set_value('ten_khoahoc',$this->form_data->ten_khoahoc); ?>"/>
                <?php echo form_error('ten_khoahoc'); ?>
				</td>
			</tr>


            <tr>
                <td valign="top">Nội Dung<span style="color:red;">*</span></td>
                <td id='noidung'>
                    <textarea rows='20' cols='20' class='ckeditor' id='ed1' name="noidung"><?php echo set_value('noidung',$this->form_data->noidung); ?></textarea>
                   <?php echo form_error('noidung'); ?>
                </td>
            </tr>
            <tr>
                <td valign="top">Thời Lượng<span style="color:red;">*</span></td>
                <td>
                    <!--<input type="text" name="thoi_luong" class="text" value="<?php// echo set_value('thoi_luong',$this->form_data->thoi_luong); ?>"/><b>Tuần-->
                    <select name="thoi_luong" id="thoi_luong">
                    <option value="<?php echo set_value('thoi_luong',$this->form_data->thoi_luong); ?>" selected><?php echo set_value('thoi_luong',$this->form_data->thoi_luong); ?>
                    </option>
                    <option value="1">01</option>
                    <option value="2">02</option>
                    <option value="3">03</option>
                    <option value="4">04</option>
                    <option value="5">05</option>
                        <option value="6">06</option>
                        <option value="7">07</option>
                        <option value="8">08</option>
                        <option value="9">09</option>
                        <option value="10">10</option>
                        <option value="11">11</option>
                        <option value="12">12</option>
                        <option value="13">13</option>
                        <option value="14">14</option>
                        <option value="15">15</option>

                 </select> <b>Tuần
                    <?php echo form_error('thoi_luong'); ?>
                </td>
            </tr>
			<tr>
				<td valign="top">Ngày Đăng<span style="color:red;">*</span></td>
				<td><input type="text" name="ngaydang" onclick="displayDatePicker('ngaydang');" class="text" value="<?php echo set_value('ngaydang',$this->form_data->ngaydang); ?>"/>
				<a href="javascript:void(0);" onclick="displayDatePicker('ngaydang');"><img src="<?php echo base_url(); ?>res/css/images/calendar.png" alt="calendar" border="0"></a>
        <?php echo form_error('ngaydang'); ?></td>
				</td>
			</tr>
            <?php if($this->session->userdata('isAdmin') == 'isAdmin'){?>
            <tr>
                <td valign="top">Trạng Thái<span style="color:red;">*</span></td>
                <td>
                    <select name="state">
                        <option  value="">Chọn Trạng Thái</option>
                        <option value="0">Không Kích Hoạt</option>
                        <option value="1">Kích Hoạt</option>

                    </select>
                    <?php echo form_error('state'); ?>
                </td>
            </tr>
            <?php }?>
			<tr>
				<td>&nbsp;</td>
				<td><input type="submit" value="Save"/></td>
			</tr>
		    </table>
        </div>
    </form>
    <br />
    <?php echo $link_back; ?>
</div>
<?php $this->load->view('admin/inc/footer'); ?>ad->view('admin/inc/footer'); ?>